<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑订单</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/admin/css/bootstrap-datetimepicker.min.css" rel="stylesheet" >
    <link href="/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/static/admin/css/animate.min.css" rel="stylesheet">
    <link href="/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/static/admin/css/style.min.css?v=4.1.0" rel="stylesheet">
    <!-- Sweet Alert -->
    <link href="/static/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-8">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑订单</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="commentWxForm" method="post" onsubmit="return toWxVaild()">
                        <input type="hidden" value="{$order.id}" name="edit_id"/>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">订单编号：</label>
                            <div class="input-group col-sm-4">
                                <input readOnly="true" type="text" class="form-control" name="wxname" required="required" aria-required="true" value="{$order.number}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">公众号：</label>
                            <div class="input-group col-sm-4">
                                <input readOnly="true" type="text" class="form-control" name="wxname" required="required" aria-required="true" value="{$order.account}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">业务员：</label>
                            <div class="input-group col-sm-4">
                                <input readOnly="true" type="text" class="form-control" required="required" aria-required="true" value="{$order.contact}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">渠道专员：</label>
                            <div class="input-group col-sm-4">
                                <input readOnly="true" type="text" class="form-control" required="required" aria-required="true" value="{$order.user_name}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">服务专员：</label>
                            <div class="input-group col-sm-4">
                                <input name="serv_name" maxlength="10" type="text" class="form-control" value="{$order.serv_name}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">服务电话：</label>
                            <div class="input-group col-sm-4">
                                <input name="serv_phone" maxlength="15" type="tel" class="form-control" value="{$order.serv_name}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">最低价格：</label>
                            <div class="input-group col-sm-4">
                                <input readOnly="true" type="text" class="form-control" required="required" aria-required="true" value="{$order.exec_price}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">订单价格：</label>
                            <div class="input-group col-sm-4">
                                <input id="price" name="price" type="text" class="form-control" required="required" aria-required="true" value="{$order.price}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">订单时间：</label>
                            <div class="input-group col-sm-4 date form_date" data-date="" data-date-format="yyyy-mm-dd" data-link-field="datepicker" data-link-format="yyyy-mm-dd">
                                <input class="form-control" size="16" type="text" value="{$order.datepicker}" readonly required="required" aria-required="true">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                            </div>
                            <input type="hidden" id="datepicker" name="datepicker" value="{$order.datepicker}" /><br/>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">订单来源：</label>
                            <div class="input-group col-sm-4">
                                <select id="source" name="source" class="show-tick form-control"  data-live-search="false">
                                    <option value="1">纽狮</option>
                                    <option value="2">报系</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">订单内容：</label>
                            <div class="input-group col-sm-4">
                                <select id="content" name="content" class="show-tick form-control"  data-live-search="false">
                                    <option value="1">贴片</option>
                                    <option value="2">软文</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">位置：</label>
                            <div class="input-group col-sm-4">
                                <select id="position" name="position" class="show-tick form-control"  data-live-search="false">
                                    <option value="头条（首）">头条（首）</option><option value="头条（尾）">头条（尾）</option><option value="二条（首）">二条（首）</option><option value="二条（尾）">二条（尾）</option><option value="三条（首）">三条（首）</option><option value="三条（尾）">三条（尾）</option><option value="四条（首）">四条（首）</option><option value="四条（尾）">四条（尾）</option><option value="五条（首）">五条（首）</option><option value="五条（尾）">五条（尾）</option><option value="六条（首）">六条（首）</option><option value="六条（尾）">六条（尾）</option><option value="七条（首）">七条（首）</option><option value="七条（尾）">七条（尾）</option><option value="八条（首）">八条（首）</option><option value="八条（尾）">八条（尾）</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit">确定</button>
                                <button class="btn btn-danger" onclick="javascript:window.history.back(); return false;">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/static/admin/js/bootstrap-datetimepicker.min.js"></script>
<script src="/static/admin/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="/static/admin/js/content.min.js?v=1.0.0"></script>
<script src="/static/admin/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/static/admin/js/plugins/validate/messages_zh.min.js"></script>
<script src="/static/admin/js/plugins/iCheck/icheck.min.js"></script>
<script src="/static/admin/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="/static/admin/js/plugins/layer/laydate/laydate.js"></script>
<script src="/static/admin/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script src="/static/admin/js/plugins/layer/layer.min.js"></script>
<script type="text/javascript">
    $('#content').change(function(){
        updateSelect($(this).val());
    });
    function updateSelect(val){
        if(val == 1) {
            $('#position').html('<option value="头条（首）">头条（首）</option><option value="头条（尾）">头条（尾）</option><option value="二条（首）">二条（首）</option><option value="二条（尾）">二条（尾）</option><option value="三条（首）">三条（首）</option><option value="三条（尾）">三条（尾）</option><option value="四条（首）">四条（首）</option><option value="四条（尾）">四条（尾）</option><option value="五条（首）">五条（首）</option><option value="五条（尾）">五条（尾）</option><option value="六条（首）">六条（首）</option><option value="六条（尾）">六条（尾）</option><option value="七条（首）">七条（首）</option><option value="七条（尾）">七条（尾）</option><option value="八条（首）">八条（首）</option><option value="八条（尾）">八条（尾）</option>');
        } else if(val == 2) {
            $('#position').html('<option value="头条">头条</option><option value="二条">二条</option><option value="三条">三条</option><option value="四条">四条</option><option value="五条">五条</option><option value="六条">六条</option><option value="七条">七条</option><option value="八条">八条</option>');
        }
    }
    //表单提交
    function toWxVaild(){
        if($('#price').val() < parseInt('{$order.exec_price}')) {
            swal("订单价格不得低于最低价格!", "", "error");
            return false;
        }
        var jz;
        var url = "./orderEdit";
        $.ajax({
            type:"POST",
            url:url,
            cache: false,
            data: new FormData($('#commentWxForm')[0]),
            processData: false,
            contentType: false,
            beforeSend:function(){
                jz = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
            },
            error: function(request) {
                layer.close(jz);
                swal("网络错误!", "", "error");
            },
            success: function(data) {
                //关闭加载层
                layer.close(jz);
                if(data.code == 1){
                    swal({
                        title: data.msg,
                        text: '',
                        type: "success",
                        showCancelButton: false,
                        confirmButtonColor: "#DD6B55",
                        confirmButtonText: "ok",
                        closeOnConfirm: false,
                        html: false
                    }, function(){
                        window.location = "{:url('index')}";
                    });
                }else{
                    swal(data.msg, "", "error");
                }
            }
        });

        return false;
    }
    $('.form_date').datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0
    });
    //表单验证
    $(document).ready(function(){
        $(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});
    });
    $.validator.setDefaults({
        highlight: function(e) {
            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
        },
        success: function(e) {
            e.closest(".form-group").removeClass("has-error").addClass("has-success")
        },
        errorElement: "span",
        errorPlacement: function(e, r) {
            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
        },
        errorClass: "help-block m-b-none",
        validClass: "help-block m-b-none"
    });
</script>
</body>
</html>